home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93c.txt / 000071_icon-group-sender _Wed Oct 6 13:59:52 1993.msg < prev    next >
Internet Message Format  |  1994-02-02  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Sun, 10 Oct 1993 10:18:00 MST
  2. Date: 6 Oct 93 13:59:52 GMT
  3. From: math.fu-berlin.de!news.belwue.de!iptc!news.wsi!peanuts!sperber@uunet.uu.net  (Michael Sperber [Mr. Preprocessor])
  4. Organization: Lehrstuhl fuer Technische Inforrmatik, Uni Tuebingen
  5. Subject: Controlling programs via pty from Icon
  6. Message-Id: <SPERBER.93Oct6145953@midi.informatik.uni-tuebingen.de>
  7. Sender: icon-group-request@cs.arizona.edu
  8. To: icon-group@cs.arizona.edu
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. I recently had to write a program which had to control an interactive
  13. ML interpreter through a pipe or something equivalent.  Since Icon is
  14. just fantastic for analyzing the output from the ML system, it was a
  15. natural choice.
  16.  
  17. It turned out that Icon pipes were inadequate for the simple reason
  18. that they can only either read or write.  Even a simple C program that
  19. opens a two-way pipe and writes the output into a file won't cut it.
  20. So I had to mess with ptys and finally came up with a program (the
  21. "flusher") that starts a job on a pty and flushes its output after
  22. every line.  That means I can do something like:
  23.  
  24.         f_ml := open(flusher || " " || compiler || " > " ||
  25.              fn_ml_msgs || " 2>&1", "pw") |
  26.  
  27. And be sure the output gets into the redirected file when as soon as a
  28. newline is printed.  It's a KLUDGE, to be sure.
  29.  
  30. Now, if anyone is interested, I can mail it.  I've written it under
  31. AIX, but using only code gleaned from Sun and Linux manuals, so it
  32. might actually work on other machines.
  33.  
  34. The more fundamental question:  Wouldn't ptys disguised as two-way
  35. pipes make a neat addition to the open function in Icon?
  36.  
  37. Cheers =8-} Chipsy
  38.